package oms.service;

import java.util.List;

import oms.dao.UserDAO;
import oms.entities.User;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImpl implements UserService {

	 @Autowired
	 private UserDAO userDAO;
	 
	
	 @Transactional
	 public void createUser(User user) {
		  
		  userDAO.createUser(user);
	 }
	
	 @Transactional
	 public void updateUser(User user) {
		  
		  userDAO.updateUser(user);
	 }
	
	 @Transactional
	 public void deleteUser(Long userId) {
		  
		  userDAO.deleteUser(userId);
 	 }
	
	 @Transactional
 	 public User getUserById(Long userId) {
			
		  return userDAO.getUserById(userId);
	 }
	
	 @Transactional
	 public User getUserByLogin(String userLogin) {
		
		  return userDAO.getUserByLogin(userLogin);
	 }

	 @Transactional
	 public User getUserByMail(String userMail) {
		
		  return userDAO.getUserByMail(userMail);
	 }
	 
	 @Transactional
	 public List<User> getAllUsers(int index, int size) {
		
		  return userDAO.getAllUsers(index, size);
	 }
	 
	 @Transactional
	 public List<User> findUser(String field, String value, String match, int index, int size) {
		
		  return userDAO.findUser(field, value, match, index, size);
	 }

	 @Transactional
	 public Integer getCount() {
		
		  return userDAO.getCount();
	 }
	
}